using System.Collections.Generic;
using GorillaEngine.ICore;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace GorillaEngine.Particles.Effects
{
    public class ExplosionEffect
    {
        public static List<Particle> CreateEffect(Texture2D texture, Vector2 emitterLocation, IRandomizer randomizer){
            var particles = new List<Particle>();

            for (int i = 0; i < 100; i++){
                particles.Add(MakeParticle(texture, emitterLocation, randomizer, .1f));
                particles.Add(MakeParticle(texture, emitterLocation, randomizer, .2f));
                particles.Add(MakeParticle(texture, emitterLocation, randomizer, .3f));
            }
            return particles;
        }
        private static Particle MakeParticle(Texture2D texture, Vector2 emitterLocation, IRandomizer rnd, float size = 1f)
        {
            var color = Color.Red;
            var timeToLive = 100 + rnd.RandomInt(0, 150);

            var randX = rnd.RandomFloat(-20, 20, 3);
            var randY = rnd.RandomFloat(-20, 20, 3);

            var acceleration = new Vector2(randX,randY);

            return Particle.Create(texture, emitterLocation, color, size, timeToLive, acceleration,1.1f);
        }
    }
}